<?php

require ( "../includes/config.php" );
require ( "../includes/CGI.php" );
require ( "../includes/SQL.php" );

$cgi = new CGI ();
$sql = new SQL ( $DBusername, $DBpassword, $server, $database );

if ( ! $sql->isConnected () )
{
  die ( $DatabaseError );
}

require ( "includes/Auth.php" );
$auth = new Auth ( $cgi, $sql, $admin_table );
$auth->checkAuth ( "index.php" );

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<title>Informa&ccedil;&otilde;es do Site</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="style.css" rel="stylesheet" type="text/css" /> 
</head> 
<body> 
<table border="0" cellpadding="1" cellspacing="0" width="100%"> 
<tbody> 
<tr> 
<td bgcolor="#333333"> <?PHP include ("header.php"); ?>
<table bgcolor="#ffffff" border="0" cellpadding="0" cellspacing="0" width="100%"> 
<tbody> 
<tr> 
<td colspan="4"> 
<table width="100%" cellpadding="0" cellspacing="0"> 
<tr> 
<td align="left" valign="top" class="leftbg"> <?PHP include ("leftmenu.php"); ?></td> 
<td valign="top"> 
<h2 align="left"><img src="images/spacer.gif" height="10" width="15" />Informa&ccedil;&otilde;es do Site </h2> 

<table width="95%" align="center" cellpadding="0" cellspacing="1">
<tr>
<td>
<p> As informa&ccedil;&otilde;es inseridas nesta p&aacute;gina ser&atilde;o os dados nos quais seus visitantes e clientes ver&atilde;o para que possam fazer contatos com os agentes imobili&aacute;rios.</p>
<p> Seu endere&ccedil;o de e-mail n&atilde;o ser&aacute; exibido no site, no entanto, este &eacute; o endere&ccedil;o de e-mail que ir&aacute; receber dos clientes em caso de d&uacute;vidas sobre quaisquer produto anunciado no site entre outras informa&ccedil;&otilde;es. Portanto, certifique-se de digitar um endere&ccedil;o de e-mail v&aacute;lido. </p></td>
</tr>
</table><br />

<?php

if ( $cgi->getValue ( "op" ) == "UpdateDetails" )
{
  $sql->execute ( "UPDATE " . $admin_table . " SET  
    adminname=" . $sql->quote ( $cgi->getValue ( "adminname" ) ) . ", 
    adminbusinessname=" . $sql->quote ( $cgi->getValue ( "adminbusinessname" ) ) . ", 
    adminaddress=" . $sql->quote ( $cgi->getValue ( "adminaddress" ) ) . ", 
    admintown=" . $sql->quote ( $cgi->getValue ( "admintown" ) ) . ", 
    admincounty=" . $sql->quote ( $cgi->getValue ( "admincounty" ) ) . ", 
    adminpostcode=" . $sql->quote ( $cgi->getValue ( "adminpostcode" ) ) . ", 
    adminemailaddress=" . $sql->quote ( $cgi->getValue ( "adminemailaddress" ) ) . ", 
    adminwebsiteurl=" . $sql->quote ( $cgi->getValue ( "adminwebsiteurl" ) ) . ", 
    admintelephone=" . $sql->quote ( $cgi->getValue ( "admintelephone" ) ) . ",
    adminfax=" . $sql->quote ( $cgi->getValue ( "adminfax" ) ) . "
" );

?>
<br />
<p align="center"><font color="red">Suas informa&ccedil;&otilde;es foram atualizadas com sucesso! </font></p>
<?php
}

$rows = $sql->execute ( "SELECT * FROM " . $admin_table . " LIMIT 1",
  SQL_RETURN_ASSOC );
$row = $rows [ 0 ];

?>
<form method="post">
<input name="op" type="hidden" value="UpdateDetails" />
<p align="center"></p>
<table width="85%" align="center" cellpadding="2" cellspacing="1">
<tr>
  <td height="32" colspan="2" align="left" valign="middle" background="images/top-menubg.gif" class="leftbg"><b>Informa&ccedil;&otilde;es do Site </b></td>  
</tr><tr>
<td align="right" bgcolor="#F3F3F3">Seu Nome:</td>
<td><input type="text" name="adminname" size="35" maxlength="150" value="<?php
  echo $cgi->htmlEncode ( $row [ "adminname" ] ); ?>" /></td>
</tr>
<tr>
<td align="right" bgcolor="#F3F3F3"> Empresa:</td>
<td><input type="text" name="adminbusinessname" size="35" maxlength="100" value="<?php
echo $cgi->htmlEncode ( $row [ "adminbusinessname" ] ); ?>" /></td>
</tr>
<tr>
<td align="right" bgcolor="#F3F3F3">Endere&ccedil;o:</td>
<td><input type="text" name="adminaddress" size="35" maxlength="100" value="<?php
echo $cgi->htmlEncode ( $row [ "adminaddress" ] ); ?>" /></td>
</tr>
<tr>
<td align="right" bgcolor="#F3F3F3">Cidade:</td>
<td><input type="text" name="admintown" size="35" maxlength="100" value="<?php echo $cgi->htmlEncode ( $row [ "admintown" ] ); ?>" /></td>
</tr>
<tr>
<td align="right" bgcolor="#F3F3F3">Estado:</td>
<td><input type="text" name="admincounty" size="35" maxlength="100" value="<?php echo $cgi->htmlEncode ( $row [ "admincounty" ] ); ?>" /></td>
</tr>
<tr>
<td align="right" bgcolor="#F3F3F3">Cep:</td>
<td><input type="text" name="adminpostcode" size="15" maxlength="100" value="<?php echo $cgi->htmlEncode ( $row [ "adminpostcode" ] ); ?>" /></td>
</tr>
<tr>
<td align="right" bgcolor="#F3F3F3">E-mail:</td>
<td><input type="text" name="adminemailaddress" size="45" maxlength="100" value="<?php echo $cgi->htmlEncode ( $row [ "adminemailaddress" ] ); ?>" /></td>
</tr>
<tr>
<td align="right" bgcolor="#F3F3F3">Website URL:</td>
<td><input type="text" name="adminwebsiteurl" size="45" maxlength="100" value="<?php echo $cgi->htmlEncode ( $row [ "adminwebsiteurl" ] ); ?>" /></td>
</tr>
<tr>
<td align="right" bgcolor="#F3F3F3">Telefone:</td>
<td><input type="text" name="admintelephone" size="25" maxlength="100" value="<?php echo $cgi->htmlEncode ( $row [ "admintelephone" ] ); ?>" /></td>
</tr>
<tr>
<td align="right" bgcolor="#F3F3F3">Fax:</td>
<td><input type="text" name="adminfax" size="25" maxlength="100" value="<?php echo $cgi->htmlEncode ( $row [ "adminfax" ] ); ?>" /></td>
</tr>
<tr>
<td align="right">&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
<p align="center">
<input type="submit" class="submit" value="Atualizar" onclick="return confirm('Tem certeza de que deseja atualizar os dados?');" />
</p>
</form>
<br /></td>
</tr> 
</table> </td> 
</tr> 
</tbody> 
</table> </td> 
</tr> 
</tbody> 
</table> <?PHP include ("footer.php"); ?>
</body>
</html>
